﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Acsys.Entity;
using MySql.Data.MySqlClient;

namespace Acsys
{
    public class CreditTypeRepository : Repository
    {
        public CreditTypeRepository()
            : base()
        {
        }
        public virtual IList GetAllParent()
        {
            try
            {
                CreditType e = new CreditType();
                OpenConnection();
                MySqlCommand aCommand = new MySqlCommand(e.GetAllParentSQL(), m_connection);
                MySqlDataReader aReader = aCommand.ExecuteReader();
                IList a = e.GetAll(aReader);
                return a;
            }
            catch (Exception x)
            {
                throw new Exception(getErrorMessage(x));
            }
            finally
            {
                m_connection.Close();
            }
        }
        public virtual IList GetAllChild()
        {
            try
            {
                CreditType e = new CreditType();
                OpenConnection();
                MySqlCommand aCommand = new MySqlCommand(e.GetAllChildSQL(), m_connection);
                MySqlDataReader aReader = aCommand.ExecuteReader();
                IList a = e.GetAll(aReader);
                return a;
            }
            catch (Exception x)
            {
                throw new Exception(getErrorMessage(x));
            }
            finally
            {
                m_connection.Close();
            }
        }
        public virtual IList GetAllChild(int parentID)
        {
            try
            {
                CreditType e = new CreditType();
                OpenConnection();
                MySqlCommand aCommand = new MySqlCommand(e.GetAllChildSQL(parentID), m_connection);
                MySqlDataReader aReader = aCommand.ExecuteReader();
                IList a = e.GetAll(aReader);
                return a;
            }
            catch (Exception x)
            {
                throw new Exception(getErrorMessage(x));
            }
            finally
            {
                m_connection.Close();
            }
        }
    }
}
